package tests;

import common.Utils;
import org.openqa.selenium.By;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2025-03-31
 * Time:0:21
 */
public class PersonalCenterPage extends Utils {
    public static String url="http://127.0.0.1:9580/index.html";
    public PersonalCenterPage() {
        super(url);
    }
    //进入个人中心页
    //修改失败
    public void PersonalFall(){
        driver.findElement(By.cssSelector("body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.dropdown > a")).click();
        driver.findElement(By.cssSelector("#index_user_settings")).click();
        //头像
        driver.findElement(By.cssSelector("#settings_avatar"));
        //修改按钮
        driver.findElement(By.cssSelector("#setting_submit_nickname"));
        //修改昵称
        driver.findElement(By.cssSelector("#setting_input_nickname")).clear();
        driver.findElement(By.cssSelector("#setting_input_nickname")).sendKeys("wangyuannn");
        driver.findElement((By.cssSelector("#setting_submit_nickname"))).sendKeys();
        //修改邮箱
        driver.findElement(By.cssSelector("#setting_input_email")).clear();
        driver.findElement(By.cssSelector("#setting_input_email")).sendKeys("123");
        driver.findElement(By.cssSelector("#setting_submit_email")).click();
        //修改电话号
        driver.findElement(By.cssSelector("#setting_input_phoneNum")).clear();
        driver.findElement(By.cssSelector("#setting_input_phoneNum")).sendKeys("123");
        driver.findElement(By.cssSelector("#setting_submit_phoneNum")).click();
        //修改密码
        driver.findElement(By.cssSelector("#settings_input_oldPassword")).sendKeys("1234");
        driver.findElement(By.cssSelector("#settings_input_newPassword")).sendKeys("1234");
        driver.findElement(By.cssSelector("#settings_input_passwordRepeat")).sendKeys("123");
        driver.findElement(By.cssSelector("#settings_submit_password")).click();
        //还在原来的页面
        String text=driver.findElement(By.cssSelector("#bit-forum-content > div.page-body > div > div > div > div.col.d-flex.flex-column > div > h3:nth-child(16)")).getText();
        String name="个人简介";
        assert name.equals(text);
    }
    //修改成功
    public void Personal() throws InterruptedException {
        driver.navigate().refresh();
        driver.findElement(By.cssSelector("body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.dropdown > a")).click();
        driver.findElement(By.cssSelector("#index_user_settings")).click();
        //头像
        driver.findElement(By.cssSelector("#settings_avatar"));
        //修改按钮
        driver.findElement(By.cssSelector("#setting_submit_nickname"));
        //修改昵称
        driver.findElement(By.cssSelector("#setting_input_nickname")).clear();
        driver.findElement(By.cssSelector("#setting_input_nickname")).sendKeys("wangyuannn");
        driver.findElement((By.cssSelector("#setting_submit_nickname"))).sendKeys();
        //修改邮箱
        driver.findElement(By.cssSelector("#setting_input_email")).clear();
        driver.findElement(By.cssSelector("#setting_input_email")).sendKeys("123");
        driver.findElement(By.cssSelector("#setting_submit_email")).click();
        //修改电话号
        driver.findElement(By.cssSelector("#setting_input_phoneNum")).clear();
        driver.findElement(By.cssSelector("#setting_input_phoneNum")).sendKeys("123");
        driver.findElement(By.cssSelector("#setting_submit_phoneNum")).click();
        //修改密码---成功
        driver.findElement(By.cssSelector("#settings_input_oldPassword")).sendKeys("1234");
        driver.findElement(By.cssSelector("#settings_input_newPassword")).sendKeys("12345");
        driver.findElement(By.cssSelector("#settings_input_passwordRepeat")).sendKeys("12345");
        //driver.findElement(By.cssSelector("#settings_submit_password")).click();
        //进入登录页面
        driver.findElement(By.cssSelector("#username")).sendKeys("xiaoyuann");
        driver.findElement(By.cssSelector("#password")).sendKeys("12345");
        driver.findElement(By.cssSelector("#submit")).click();
        Thread.sleep(3000);
        //检查点击确定之后是否登陆成功，进入会话列表页
        String expect="首页";
        String text=driver.findElement(By.cssSelector("#article_list_board_title")).getText();
        assert expect.equals(text);
        Thread.sleep(3000);
    }


}
